//
//  DatePickerPageViewController.m
//  pickers选取器
//
//  Created by 小白 on 16/2/23.
//  Copyright © 2016年 小白. All rights reserved.
//

#import "DatePickerPageViewController.h"

@interface DatePickerPageViewController ()
@property (weak, nonatomic) IBOutlet UILabel *labelShowmessage;
@property (weak, nonatomic) IBOutlet UIDatePicker *datePicker;

@end

@implementation DatePickerPageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)datePickervalue:(id)sender {
    NSDate *now = [NSDate date];
    NSTimeInterval t = [now timeIntervalSinceDate:self.datePicker.date];
    self.labelShowmessage.text = [NSString stringWithFormat:@"你所选的时间与当前时间间隔%g",fabs(t/60.0/60.0/24.0)];
}
- (IBAction)btnPress:(id)sender {
    //NSDate -> NSString
    NSDateFormatter *f = [[NSDateFormatter alloc]init];
    [f setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSString *str = [f stringFromDate:self.datePicker.date];
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"你所选的时间是" message:str  delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
    [alert show];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
